/**
    重写vant-popup
        主要是解决手机物理返回不会关闭vant的弹层之类的组件，而是返回页面的问题
 */

<script>
import { Popup } from 'vant'

export default {
    extends: Popup,
    mounted () {
        // 打开之后添加到全局待关闭变量中
        this.$on('opened', _ => {
            this.vantToBeClosed.push(this)
        })

        // 关闭删除变量中的实例
        this.$on('close', _ => {
            let index = this.vantToBeClosed.findIndex(item => item._uid == this._uid)

            if (index > -1) {
                this.vantToBeClosed.splice(index, 1)
            }
        })
    }
}
</script>